package com.yuju.controller.pub;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONObject;
import com.yuju.common.Result;
import com.yuju.controller.base.BaseController;
import com.yuju.enums.ReturnStatusEnum;
import com.yuju.rpt.enums.CheckinRoomTypeReturnEnum;
import com.yuju.rpt.model.CheckinRoomTypeModel;
import com.yuju.rpt.service.ICheckinRoomTypeService;
import com.yuju.util.Utils;
import com.yuju.vo.rpt.CheckinRoomTypeVO;

/**
 * 类名：RptCheckinRoomTypeController  <br />
 *
 * 功能：
 *
 * @author : jiaokn <br />
 * @Date : 2018年2月5日 上午11:21:13  <br />
 * @version : 1.1 <br />
 */
@Controller
@RequestMapping("rptCheckinRoomType")
public class RptCheckinRoomTypeController extends BaseController<CheckinRoomTypeVO, CheckinRoomTypeModel> {
	
	@Autowired
	private ICheckinRoomTypeService checkinRoomTyepService;
	
	/**
	 * 功能：<br/>
	 *
	 * @author jiaokn
	 * @Date 2018年2月5日 下午1:51:41 <br/>
	 */
	@RequestMapping("get")
	@ResponseBody
	public Result get(@RequestBody JSONObject obj){
		CheckinRoomTypeVO checkinRoomTypeVO = obj.toJavaObject(CheckinRoomTypeVO.class);
		List<CheckinRoomTypeModel> list = checkinRoomTyepService.list(convert(checkinRoomTypeVO));
		Result result = new Result();
		if(Utils.isNotNull(list)){
			result.setRows(list);
			result.setStatus(ReturnStatusEnum.SUCCESS.getCode());
			result.setMsg(ReturnStatusEnum.SUCCESS.getDesc());
			result.setReturnCode(CheckinRoomTypeReturnEnum.CHECKINROOMTYPE_GET_SUCCESS.getCode());
			result.setReturnMsg(CheckinRoomTypeReturnEnum.CHECKINROOMTYPE_GET_SUCCESS.getDesc());
		}else{
			result.setStatus(ReturnStatusEnum.FAILURE.getCode());
			result.setMsg(ReturnStatusEnum.FAILURE.getDesc());
			result.setReturnCode(CheckinRoomTypeReturnEnum.CHECKINROOMTYPE_GET_FAILURE.getCode());
			result.setReturnMsg(CheckinRoomTypeReturnEnum.CHECKINROOMTYPE_GET_FAILURE.getDesc());
		}
		return result;
	}
	
	/**
	 * 功能：<br/>
	 *
	 * @author jiaokn
	 * @Date 2018年2月5日 下午1:51:30 <br/>
	 */
	@RequestMapping("getSum")
	@ResponseBody
	public Result getSum(@RequestBody JSONObject obj){
		CheckinRoomTypeVO checkinRoomTypeVO = obj.toJavaObject(CheckinRoomTypeVO.class);
		Result result = new Result();
		CheckinRoomTypeModel model = checkinRoomTyepService.getCheckinStatByRoomTypeSum(convert(checkinRoomTypeVO));
		if(Utils.isNotNull(model)){
			result.setData(model);
			result.setStatus(ReturnStatusEnum.SUCCESS.getCode());
			result.setMsg(ReturnStatusEnum.SUCCESS.getDesc());
			result.setReturnCode(CheckinRoomTypeReturnEnum.CHECKINROOMTYPE_SUM_SUCCESS.getCode());
			result.setReturnMsg(CheckinRoomTypeReturnEnum.CHECKINROOMTYPE_SUM_SUCCESS.getDesc());
		}else{
			result.setStatus(ReturnStatusEnum.FAILURE.getCode());
			result.setMsg(ReturnStatusEnum.FAILURE.getDesc());
			result.setReturnCode(CheckinRoomTypeReturnEnum.CHECKINROOMTYPE_SUM_FAILURE.getCode());
			result.setReturnMsg(CheckinRoomTypeReturnEnum.CHECKINROOMTYPE_SUM_FAILURE.getDesc());
		}
		return result;
		
	}
}
